# # -*- coding:utf-8 -*-
# """Created By Corvo"""
#
# __version__ = 7
#
# import os
#
# """初始化新模块"""
#
#
# def create_module():
#     path = "../../../%s" % module_name
#     if not os.path.exists(path):
#         os.makedirs(path)
#
#     init = '''# -*- coding:utf-8 -*-
# """Created By Corvo"""
#
# from client import {0}ModuleClient
# from server import {0}ModuleServer
#
# __all__ = ["{0}ModuleServer", "{0}ModuleClient"]
# '''.format(module_name.capitalize())
#
#     server = '''# -*- coding:utf-8 -*-
# """Created By Corvo"""
#
# from const import *
# from ..mdk.module.system.base import *
#
#
# class %sModuleServer(ModuleServerBase):
#     """%s模块服务端"""
#     __mVersion__ = 1
#     __identifier__ = ModuleEnum.identifier
# ''' % (module_name.capitalize(), module_ch)
#
#     client = '''# -*- coding:utf-8 -*-
# """Created By Corvo"""
#
# from const import *
# from ..mdk.module.system.base import *
#
#
# class %sModuleClient(ModuleClientBase):
#     """%s模块客户端"""
#     __mVersion__ = 1
#     __identifier__ = ModuleEnum.identifier
# ''' % (module_name.capitalize(), module_ch)
#
#     const = '''# -*- coding:utf-8 -*-
# """Created By Corvo"""
#
#
# class ModuleEnum(object):
#     """模块枚举"""
#     identifier = "%s"
#
#
# class ModuleEvent(object):
#     """模块事件"""
# ''' % identifier
#
#     with open(path + "/__init__.py", "w") as f:
#         f.write(init)
#     with open(path + "/server.py", "w") as f:
#         f.write(server)
#     with open(path + "/client.py", "w") as f:
#         f.write(client)
#     with open(path + "/const.py", "w") as f:
#         f.write(const)
#
#
# def create_rpc_module():
#     path = "../../../%s" % module_name
#     if not os.path.exists(path):
#         os.makedirs(path)
#
#     init = '''# -*- coding:utf-8 -*-
# """Created By Corvo"""
#
# from client import {0}ModuleClient
# from server import {0}ModuleServer
#
# __all__ = ["{0}ModuleServer", "{0}ModuleClient"]
# '''.format(module_name.capitalize())
#
#     server = '''# -*- coding:utf-8 -*-
# """Created By Corvo"""
#
# from const import *
# from ..mdk.module.system.base import *
#
# if __name__ == '__main__':
#     from client import {0}ModuleClient
#
#
# class {0}ModuleServer(ModuleServerBase):
#     """{1}模块服务端"""
#     __mVersion__ = 1
#     __identifier__ = ModuleEnum.identifier
#
#     def __init__(self):
#         super({0}ModuleServer, self).__init__()
#         self.rpc = self.ModuleSystem.CreateRpcModule(self, ModuleEnum.identifier)
#
#     def OnDestroy(self):
#         self.rpc.Discard()
#         del self.rpc
#         super({0}ModuleServer, self).OnDestroy()
#
#     @property
#     def client(self, target=None):
#         # type: (str) -> {0}ModuleClient
#         return self.rpc(target)
#
#     def client_recall(self, target, recall):
#         # type: (str, any) -> {0}ModuleClient
#         return self.rpc(target, recall)
# '''.format(module_name.capitalize(), module_ch)
#
#     client = '''# -*- coding:utf-8 -*-
# """Created By Corvo"""
#
# from const import *
# from ..mdk.module.system.base import *
#
# if __name__ == '__main__':
#     from server import {0}ModuleServer
#
#
# class {0}ModuleClient(ModuleClientBase):
#     """{1}模块客户端"""
#     __mVersion__ = 1
#     __identifier__ = ModuleEnum.identifier
#
#     def __init__(self):
#         super({0}ModuleClient, self).__init__()
#         self.rpc = self.ModuleSystem.CreateRpcModule(self, ModuleEnum.identifier)
#
#     def OnDestroy(self):
#         self.rpc.Discard()
#         del self.rpc
#         super({0}ModuleClient, self).OnDestroy()
#
#     @property
#     def server(self):
#         # type: () -> {0}ModuleServer
#         return self.rpc
#
#     def server_recall(self, recall):
#         # type: (any) -> {0}ModuleServer
#         return self.rpc(recall)
# '''.format(module_name.capitalize(), module_ch)
#
#     const = '''# -*- coding:utf-8 -*-
# """Created By Corvo"""
#
#
# class ModuleEnum(object):
#     """模块枚举"""
#     identifier = "%s"
#
#
# class ModuleEvent(object):
#     """模块事件"""
# ''' % identifier
#
#     with open(path + "/__init__.py", "w") as f:
#         f.write(init)
#     with open(path + "/server.py", "w") as f:
#         f.write(server)
#     with open(path + "/client.py", "w") as f:
#         f.write(client)
#     with open(path + "/const.py", "w") as f:
#         f.write(const)
#
#
# if __name__ == '__main__':
#     module_name = raw_input("模块名称：")
#     module_ch = raw_input("模块中文名：")
#     is_rpc = raw_input("非rpc模块：[输入任何内容使用rpc模块]")
#     root = ""
#
#     for _path in os.listdir("../../../../"):
#         if _path.startswith("scripts_"):
#             root = _path.split("_")[-1]
#             break
#     identifier = "%s.%s" % (root, module_name)
#
#     create_module() if not is_rpc else create_rpc_module()
#
#     print "执行完毕"
